<template>
  <div class="cart">
    <!-- 渲染商品信息 -->
    <van-swipe-cell v-for="item in cartData" :key="item.prodid">
      <van-checkbox v-model="checked"></van-checkbox>
  <van-card 
   
    :price='item.prodPrice'
    class="goods-card"
    :thumb='item.prodPicture'
  />
  <template #right>
    <van-button square text="删除" type="danger" class="delete-button" />
  </template>
  
</van-swipe-cell>

    <!-- 底部提交订单栏 -->
    <van-submit-bar :price="3050" button-text="提交订单" @submit="onSubmit" safe-area-inset-bottom>
  <van-checkbox v-model="checked">全选</van-checkbox>
  <template #tip>
    你的收货地址不支持配送, <span @click="onClickLink">修改地址</span>
  </template>
</van-submit-bar>
  </div>
</template>

<script lang="ts" setup>
import useCartStore from '@/store/modules/cart';
import { ref } from 'vue';
import {alreadyHasCart} from '../../api/cart'

import useUserStore from '@/store/modules/user';
const userStore=useUserStore()
const checked=ref(false)
const store=useCartStore()

const cartData=ref([])



//提交订单方法
const onSubmit=()=>{
  console.log('提交订单方法')
}
//修改地址方法
const onClickLink=()=>{
  console.log('修改地址方法')
}
//获取用户已有购物车信息
const userCart=async()=>{
  const result=await alreadyHasCart(userStore.token)
   cartData.value=result.data.data.cart
   console.log('渲染数组：',cartData.value)

  console.log(result)

}
userCart()


</script>

<style  lang="less" scoped>

 .goods-card {
    margin: 0;
    background-color: white;
  }

  .delete-button {
    height: 100%;
  }

</style>
